/* -----------------------------------------------------------------------
 * Becky Kluth
 * CS 362
 * Assignment 3: unittest2.c test of function isGameOver() in dominion.c
 *
 * unittest2: unittest2.c dominion.o rngs.o
 *      gcc -o unittest2 -g  unittest2.c dominion.o rngs.o $(CFLAGS)
 * -----------------------------------------------------------------------
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

//set NOISY_TEST to 0 to remove printfs from output (this macro take from the example)
#define NOISY_TEST 0

int main() {
	int seed = 1000;										//initiate a two player game
    int numPlayer = 2;
    int k[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};
    struct gameState G;
	int over;

    initializeGame(numPlayer, k, seed, &G);

    printf ("Testing isGameOver():\n");
	
	over = isGameOver(&G);				//test initialized game
	assert(over == 0);
#if (NOISY_TEST == 1)
	printf("Game is over: %d\n", over);
#endif

	G.supplyCount[province] = 0;		//test with no more provinces
	over = isGameOver(&G);				
	assert(over == 1);
#if (NOISY_TEST == 1)
	printf("Game is over: %d\n", over);
#endif

	G.supplyCount[province] = 1;
	over = isGameOver(&G);				//test with returned provinces
	assert(over == 0);
#if (NOISY_TEST == 1)
	printf("Game is over: %d\n", over);
#endif

	G.supplyCount[1] = 0;				//test with 2 empty supply piles
	G.supplyCount[5] = 0;
	over = isGameOver(&G);				
	assert(over == 0);
#if (NOISY_TEST == 1)
	printf("Game is over: %d\n", over);
#endif

	G.supplyCount[7] = 0;				//test with 3 total empty supply piles
	over = isGameOver(&G);				
	assert(over == 1);
#if (NOISY_TEST == 1)
	printf("Game is over: %d\n", over);
#endif

	G.supplyCount[7] = -1;				//test with 3 total empty supply piles, one pile with -1 cards
	over = isGameOver(&G);				
	//assert(over == 1);				//finds a bug--commented out to make Makefile work
#if (NOISY_TEST == 1)
	printf("Game is over: %d\n", over);
#endif

    printf("All tests passed!\n");

    return 0;
}